<<<<<<< HEAD
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class GroupManager {
    private List<String> groups = new ArrayList<>();
    private RandomPicker randomPicker;

    public GroupManager() {
        // 添加一些默认小组
        groups.add("小组 A");
        groups.add("小组 B");
        groups.add("小组 C");
    }

    public List<String> getGroups() {
        return groups;
    }

    // 设置RandomPicker实例，以便能调用其方法
    public void setRandomPicker(RandomPicker randomPicker) {
        this.randomPicker = randomPicker;
    }

    public void manageGroups(Scanner scanner) {
        System.out.println("小组管理");
        System.out.println("1. 增删小组");
        System.out.println("2. 维护小组");
        System.out.println("3. 小组列表");
        System.out.print("请选择操作: ");
        int choice = scanner.nextInt();
        scanner.nextLine(); // 清除换行符

        switch (choice) {
            case 1:
                System.out.println("增删小组");
                System.out.println("1. 新增小组");
                System.out.println("2. 删除小组");
                System.out.print("请选择操作: ");
                int addOrDeleteChoice = scanner.nextInt();
                scanner.nextLine(); // 清除换行符

                switch (addOrDeleteChoice) {
                    case 1:
                        System.out.print("输入小组名称: ");
                        String groupName = scanner.nextLine();
                        groups.add(groupName);
                        System.out.println("小组 " + groupName + " 已新增");
                        break;
                    case 2:
                        System.out.print("输入要删除的小组名称: ");
                        String groupToDelete = scanner.nextLine();

                        if (groups.contains(groupToDelete)) {
                            groups.remove(groupToDelete);
                            System.out.println("小组 " + groupToDelete + " 已删除");
                        } else {
                            System.out.println("小组 " + groupToDelete + " 不存在");
                        }
                        break;
                    default:
                        System.out.println("无效选择");
                }
                break;
            case 2:
                System.out.println("小组维护");
                System.out.println("1. 修改小组名称");
                System.out.println("2. 记录小组成绩");
                System.out.print("请选择操作: ");
                int recordChoice = scanner.nextInt();
                scanner.nextLine(); // 清除换行符

                switch (recordChoice) {
                    case 1:
                        System.out.print("输入要修改的小组名称: ");
                        String oldGroupName = scanner.nextLine();
                        System.out.print("新的小组名称: ");
                        String newGroupName = scanner.nextLine();

                        if (groups.contains(oldGroupName)) {
                            int index = groups.indexOf(oldGroupName);
                            groups.set(index, newGroupName);
                            System.out.println("小组名称已修改为 " + newGroupName);
                        } else {
                            System.out.println("小组 " + oldGroupName + " 不存在");
                        }
                        break;
                    case 2:
                        System.out.print("输入小组名称: ");
                        String groupNameForScore = scanner.nextLine();

                        if (groups.contains(groupNameForScore)) {
                            System.out.print("输入该小组的成绩: ");
                            int score = scanner.nextInt();
                            scanner.nextLine(); // 清除换行符

                            // 调用RandomPicker的recordGroupScore方法记录成绩
                            randomPicker.recordGroupScore(groupNameForScore, score);

                            System.out.println("已记录小组 " + groupNameForScore + " 的成绩为 " + score);
                        } else {
                            System.out.println("小组 " + groupNameForScore + " 不存在");
                        }
                        break;
                    default:
                        System.out.println("无效选择");
                }
                break;
            case 3:
                System.out.println("小组列表:");
                for (String g : groups) {
                    System.out.println(g);
                }
                break;
            default:
                System.out.println("无效选择");
        }
    }
=======
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class GroupManager {
    private List<String> groups = new ArrayList<>();
    private RandomPicker randomPicker;

    public GroupManager() {
        // 添加一些默认小组
        groups.add("小组 A");
        groups.add("小组 B");
        groups.add("小组 C");
    }

    public List<String> getGroups() {
        return groups;
    }

    // 设置RandomPicker实例，以便能调用其方法
    public void setRandomPicker(RandomPicker randomPicker) {
        this.randomPicker = randomPicker;
    }

    public void manageGroups(Scanner scanner) {
        System.out.println("小组管理");
        System.out.println("1. 增删小组");
        System.out.println("2. 维护小组");
        System.out.println("3. 小组列表");
        System.out.print("请选择操作: ");
        int choice = scanner.nextInt();
        scanner.nextLine(); // 清除换行符

        switch (choice) {
            case 1:
                System.out.println("增删小组");
                System.out.println("1. 新增小组");
                System.out.println("2. 删除小组");
                System.out.print("请选择操作: ");
                int addOrDeleteChoice = scanner.nextInt();
                scanner.nextLine(); // 清除换行符

                switch (addOrDeleteChoice) {
                    case 1:
                        System.out.print("输入小组名称: ");
                        String groupName = scanner.nextLine();
                        groups.add(groupName);
                        System.out.println("小组 " + groupName + " 已新增");
                        break;
                    case 2:
                        System.out.print("输入要删除的小组名称: ");
                        String groupToDelete = scanner.nextLine();

                        if (groups.contains(groupToDelete)) {
                            groups.remove(groupToDelete);
                            System.out.println("小组 " + groupToDelete + " 已删除");
                        } else {
                            System.out.println("小组 " + groupToDelete + " 不存在");
                        }
                        break;
                    default:
                        System.out.println("无效选择");
                }
                break;
            case 2:
                System.out.println("小组维护");
                System.out.println("1. 修改小组名称");
                System.out.println("2. 记录小组成绩");
                System.out.print("请选择操作: ");
                int recordChoice = scanner.nextInt();
                scanner.nextLine(); // 清除换行符

                switch (recordChoice) {
                    case 1:
                        System.out.print("输入要修改的小组名称: ");
                        String oldGroupName = scanner.nextLine();
                        System.out.print("新的小组名称: ");
                        String newGroupName = scanner.nextLine();

                        if (groups.contains(oldGroupName)) {
                            int index = groups.indexOf(oldGroupName);
                            groups.set(index, newGroupName);
                            System.out.println("小组名称已修改为 " + newGroupName);
                        } else {
                            System.out.println("小组 " + oldGroupName + " 不存在");
                        }
                        break;
                    case 2:
                        System.out.print("输入小组名称: ");
                        String groupNameForScore = scanner.nextLine();

                        if (groups.contains(groupNameForScore)) {
                            System.out.print("输入该小组的成绩: ");
                            int score = scanner.nextInt();
                            scanner.nextLine(); // 清除换行符

                            // 调用RandomPicker的recordGroupScore方法记录成绩
                            randomPicker.recordGroupScore(groupNameForScore, score);

                            System.out.println("已记录小组 " + groupNameForScore + " 的成绩为 " + score);
                        } else {
                            System.out.println("小组 " + groupNameForScore + " 不存在");
                        }
                        break;
                    default:
                        System.out.println("无效选择");
                }
                break;
            case 3:
                System.out.println("小组列表:");
                for (String g : groups) {
                    System.out.println(g);
                }
                break;
            default:
                System.out.println("无效选择");
        }
    }
>>>>>>> origin/master
}